import { createRouter, createWebHashHistory } from 'vue-router'
import Layout from '@/views/Layout'
import Login from '@/views/Login'
import Category from '@/views/Category'
import Home from '@/views/Home'
import Good from '@/views/Good'
import Cart from '@/views/Cart'
import Settle from '@/views/Settle'
import Pay from '@/views/Pay'
import PayResult from '@/views/Pay/PayResult.vue'
// 这里配置路由对应关键 path - component
const routes = [
  {
    path: '/',
    component: Layout,
    children: [
      {
        path: '',
        // 二级路由为空时 默认的二级路由渲染 当浏览器输入'/'的时候 首先会在
        // 二级路由的出口位置 先把Home渲染出来
        component: Home
      },
      {
        path: 'category/:id',
        component: Category
      },
      {
        path: 'good/:id',
        component: Good
      },
      {
        path: 'cart',
        component: Cart
      },
      {
        path: 'settle',
        component: Settle
      },
      {
        path: 'pay',
        component: Pay
      },
      {
        path: 'pay/callback',
        component: PayResult
      }
    ]
  },
  {
    path: '/login',
    component: Login
  }
]

const router = createRouter({
  history: createWebHashHistory(),
  routes
})

export default router
